package vip.zcn.webmanagement.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import vip.zcn.webmanagement.utils.AliOSSUtils;
import vip.zcn.webmanagement.utils.Result;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@Slf4j
@RestController
public class UploadController {

    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result upload(@RequestParam(value = "image") MultipartFile image) throws IOException {
        String url = aliOSSUtils.upload(image);
        log.info("上传成功，文件路径为：{}", url);
        return Result.success(url);
    }
}
